package day7;

public class Student2 {
    private String name;
    private int age;
    private String sex;
    private String professional;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        if (name!=null){
            this.name = name;
        }else {
            System.out.println("姓名不能为空，默认为张三");
            this.name="张三";
        }

    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex="男";

    }

    public String getProfessional() {
        return professional;
    }

    public void setProfessional(String professional) {
        if("ACCP".equals(professional)){
            this.professional = professional;
        }else {
            System.out.println("专业输入错误");
        }

    }

    public void print(){
        System.out.println("自我介绍");
        System.out.println("姓名:"+name);
        System.out.println("年龄："+age);
        System.out.println("性别："+sex);
        System.out.println("专业："+professional);
    }
}
